<%--
  Created by IntelliJ IDEA.
  User: zx
  Date: 2017/7/2
  Time: 14:25
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<head>
    <jsp:include page="../common.jsp"></jsp:include>
</head>
<div>
    <div class="input-group">
        <span class="input-group-addon">阶段名称</span>
        <input type="text" id="proTitle" class="form-control" placeholder="阶段名称">
    </div>
    <textarea id="proContent" name="content" class="form-control kindeditor" style="height:100px;">Hello, world!</textarea>;
    <div id="tableUploader" class="uploader">
        <div class="uploader-message text-center">
            <div class="content"></div>
            <button type="button" class="close">×</button>
        </div>
        <table class="table table-bordered">
            <thead>
            <tr>
                <th colspan="2">文件名</th>
                <th style="width: 100px">大小</th>
                <th style="width: 160px; text-align: center;">状态/操作</th>
            </tr>
            </thead>
            <tbody class="uploader-files">
                <tr class="file template">
                    <td style="width: 38px; padding: 3px"><div class="file-icon"></div></td>
                    <td style="padding: 0">
                        <div style="position: relative; padding: 8px;">
                            <strong class="file-name"></strong>
                            <div class="file-progress-bar"></div>
                        </div>
                    </td>
                    <td><span class="file-size text-muted"></span></td>
                    <td class="actions text-right" style="padding: 0 4px;">
                        <div class="file-status" data-toggle="tooltip" style="margin: 8px;"><i class="icon"></i> <span class="text"></span></div>
                        <a data-toggle="tooltip" class="btn btn-link btn-download-file" target="_blank"><i class="icon icon-download-alt"></i></a>
                        <button type="button" data-toggle="tooltip" class="btn btn-link btn-reset-file" title="Repeat"><i class="icon icon-repeat"></i></button>
                        <button type="button" data-toggle="tooltip" class="btn btn-link btn-rename-file" title="Rename"><i class="icon icon-pencil"></i></button>
                        <button type="button" data-toggle="tooltip" title="Remove" class="btn btn-link btn-delete-file"><i class="icon icon-trash text-danger"></i></button>
                    </td>
                </tr>
            </tbody>
            <tfoot>
            <tr>
                <td colspan="4" style="padding: 4px 0">
                    <div style="position: relative;">
                        <div class="uploader-status pull-right text-muted" style="margin-top: 5px;"></div>
                        <button type="button" class="btn btn-link uploader-btn-browse"><i class="icon icon-plus"></i> 选择文件</button>
                        <button type="button" class="btn btn-link uploader-btn-start"><i class="icon icon-cloud-upload"></i> 开始上传</button>
                    </div>
                </td>
            </tr>
            </tfoot>
        </table>
    </div>
    <button class="btn btn-primary" type="button" id="saveBtn">保存</button>&nbsp;&nbsp;&nbsp;&nbsp;
    <button class="btn btn-primary" type="button">保存</button>
</div>
<script>
    $(function(){
        var filePath = "";
        $('#tableUploader').uploader({
            url: basePath + "/activiti/processManager/uploadFile",
            chunk_size : "5mb",
            unique_names : true
//            ,
//            responseHandler: function(responseObject, file) {
//                // 当服务器返回的文本内容包含 `'error'` 文本时视为上传失败
//                console.log(responseObject.response);
//                if(responseObject.response.indexOf('error') != -1) {
//                    return '上传失败。服务器返回了一个错误：' + responseObject.response;
//                }else{
//                    return responseObject.response;
//                }
//            }
        }).on("onFileUploaded",function(file, responseObject){
            console.log(file.response);
            console.log(responseObject);
            filePath += responseObject.name + ",";
            console.log(responseObject.response);
        }).on("onError",function(error){
            console.log(error);
        });
        var editor = KindEditor.create('textarea.kindeditor', {
            basePath: '/dist/lib/kindeditor/',
            bodyClass : 'article-content',
            resizeType : 1,
            allowPreviewEmoticons : false,
            allowImageUpload : false,
            items : [
                'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
                'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
                'insertunorderedlist'//, '|', 'emoticons', 'image', 'link'
            ]
        });
        var widthEditor = editor.width;
        $(".ke-container").css('width', widthEditor);

        $("#saveBtn").click(function(){
            $.ajax({
                url : basePath + '/insertProInfo',
                data : {"title" : $("#proTitle").val(),"content" : $("#proContent").val(),"path" : filePath},
                type : "post",
                error : function(){

                },
                success : function(data){

                }
            });
        });
    });
</script>



